﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:Converters="clr-namespace:MahApps.Metro.Converters">

    <Converters:ToUpperConverter x:Key="ToUpperConverter" />
    <Converters:ToLowerConverter x:Key="ToLowerConverter" />

    <Style x:Key="MetroFlatButton"
           TargetType="{x:Type Button}">
        <Setter Property="Background"
                Value="{DynamicResource FlatButtonBackgroundBrush}" />
        <Setter Property="Foreground"
                Value="{DynamicResource FlatButtonForegroundBrush}" />
        <Setter Property="FontSize"
                Value="{DynamicResource FlatButtonFontSize}" />
        <Setter Property="Padding"
                Value="10,5,10,5" />
        <Setter Property="BorderThickness"
                Value="0" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Border x:Name="Border"
                            Margin="0"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          Margin="{TemplateBinding Padding}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                          RecognizesAccessKey="True" />
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsPressed"
                                 Value="True">
                            <Setter Property="Background"
                                    Value="{DynamicResource FlatButtonPressedBackgroundBrush}"
                                    TargetName="Border" />
                            <Setter Property="Foreground"
                                    Value="{DynamicResource FlatButtonPressedForegroundBrush}" />
                        </Trigger>
                        <Trigger Property="IsEnabled"
                                 Value="False">
                            <Setter Property="Foreground"
                                    Value="{DynamicResource GrayBrush2}" />
                        </Trigger>
                        <Trigger Property="IsMouseOver"
                                 Value="True">
                            <Setter Property="Background"
                                    Value="DarkGray" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="MetroCircleButtonFocusVisual">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Control}">
                    <Ellipse Margin="8"
                             Stroke="{DynamicResource BlackBrush}"
                             StrokeDashArray="2 2"
                             StrokeThickness="1"
                             SnapsToDevicePixels="True" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- style for WP7/Circle button -->
    <Style x:Key="MetroCircleButtonStyle"
           TargetType="{x:Type Button}">
        <Setter Property="FocusVisualStyle"
                Value="{StaticResource MetroCircleButtonFocusVisual}" />
        <Setter Property="Background"
                Value="Transparent" />
        <Setter Property="BorderThickness"
                Value="2" />
        <Setter Property="BorderBrush"
                Value="{DynamicResource GrayBrush3}" />
        <Setter Property="HorizontalContentAlignment"
                Value="Center" />
        <Setter Property="VerticalContentAlignment"
                Value="Center" />
        <Setter Property="Padding"
                Value="1" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Grid>
                        <Ellipse Fill="{TemplateBinding Background}"
                                 Margin="4"
                                 StrokeThickness="0" />
                        <Ellipse x:Name="ellipsebg"
                                 Fill="{DynamicResource BlackBrush}"
                                 Opacity="0"
                                 Margin="4"
                                 StrokeThickness="0" />
                        <Ellipse x:Name="ellipse"
                                 Margin="4"
                                 Stroke="{TemplateBinding BorderBrush}"
                                 StrokeThickness="{Binding RelativeSource={x:Static RelativeSource.TemplatedParent}, Path=BorderThickness.Left}" />
                        <ContentPresenter x:Name="content"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          Margin="{TemplateBinding Padding}"
                                          RecognizesAccessKey="True"
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsPressed"
                                 Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="ellipsebg"
                                                         Storyboard.TargetProperty="Opacity"
                                                         From="0"
                                                         To="0.3"
                                                         Duration="0:0:0" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.EnterActions>
                            <!-- some out fading -->
                            <Trigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="ellipsebg"
                                                         Storyboard.TargetProperty="Opacity"
                                                         To="0"
                                                         Duration="0:0:0.5" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.ExitActions>
                        </Trigger>
                        <Trigger Property="IsMouseOver"
                                 Value="True">
                            <Setter TargetName="ellipse"
                                    Property="Opacity"
                                    Value="1" />
                        </Trigger>
                        <Trigger Property="IsMouseOver"
                                 Value="False">
                            <Setter TargetName="ellipse"
                                    Property="Opacity"
                                    Value="0.7" />
                        </Trigger>
                        <Trigger Property="IsEnabled"
                                 Value="false">
                            <Setter Property="Foreground"
                                    Value="{DynamicResource GrayBrush7}" />
                            <Setter TargetName="ellipse"
                                    Property="Opacity"
                                    Value="0.3" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- "Chromeless" style for buttons -->
    <ControlTemplate x:Key="ChromelessButtonTemplate"
                     TargetType="{x:Type ButtonBase}">
        <Grid Background="{TemplateBinding Background}">
            <ContentPresenter x:Name="contentPresenter"
                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                              Margin="{TemplateBinding Padding}"
                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                              RecognizesAccessKey="True"
                              Opacity="0.75" />
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver"
                     Value="True">
                <Setter TargetName="contentPresenter"
                        Property="Opacity"
                        Value="1" />
            </Trigger>
            <Trigger Property="IsMouseOver"
                     Value="False">
                <Setter TargetName="contentPresenter"
                        Property="Opacity"
                        Value=".5" />
            </Trigger>
            <Trigger Property="IsEnabled"
                     Value="false">
                <Setter Property="Foreground"
                        Value="#ADADAD" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    <Style x:Key="ChromelessButtonStyle"
           TargetType="{x:Type ButtonBase}">
        <Setter Property="Background"
                Value="{DynamicResource TransparentWhiteBrush}" />
        <Setter Property="Foreground"
                Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
        <Setter Property="HorizontalContentAlignment"
                Value="Center" />
        <Setter Property="VerticalContentAlignment"
                Value="Center" />
        <Setter Property="Padding"
                Value="1" />
        <Setter Property="Template"
                Value="{StaticResource ChromelessButtonTemplate}" />
    </Style>

    <!-- base button style for min, max and close window buttons -->
    <Style x:Key="MetroBaseWindowButtonStyle"
           TargetType="{x:Type Button}">
        <Setter Property="Background"
                Value="{DynamicResource TransparentWhiteBrush}" />
        <Setter Property="Foreground"
                Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
        <Setter Property="HorizontalContentAlignment"
                Value="Center" />
        <Setter Property="VerticalContentAlignment"
                Value="Center" />
        <Setter Property="Padding"
                Value="1" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Grid Background="{TemplateBinding Background}">
                        <ContentPresenter x:Name="contentPresenter"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          Margin="{TemplateBinding Padding}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                          RecognizesAccessKey="True"
                                          Opacity="0.75" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver"
                                 Value="True">
                            <Setter TargetName="contentPresenter"
                                    Property="Opacity"
                                    Value="1" />
                        </Trigger>
                        <Trigger Property="IsMouseOver"
                                 Value="False">
                            <Setter TargetName="contentPresenter"
                                    Property="Opacity"
                                    Value=".5" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsMouseOver"
                     Value="True">
                <Setter Property="Background"
                        Value="{DynamicResource SemiTransparentWhiteBrush}" />
            </Trigger>
            <Trigger Property="IsPressed"
                     Value="True">
                <Setter Property="Background"
                        Value="{DynamicResource HighlightBrush}" />
            </Trigger>
            <Trigger Property="IsEnabled"
                     Value="false">
                <Setter Property="Foreground"
                        Value="#ADADAD" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <!-- default button style for min, max and close window buttons -->
    <Style x:Key="MetroWindowButtonStyle"
           TargetType="{x:Type Button}"
           BasedOn="{StaticResource MetroBaseWindowButtonStyle}">
        <Setter Property="FocusVisualStyle"
                Value="{x:Null}" />
        <Setter Property="IsTabStop"
                Value="False" />
        <Setter Property="Width"
                Value="34" />
        <Setter Property="MaxHeight"
                Value="34" />
        <Setter Property="Padding"
                Value="0" />
    </Style>

    <!-- obsolete, will be deleted in 0.14 -->
    <Style x:Key="IronicallyNamedChromelessButtonStyle"
           TargetType="{x:Type Button}"
           BasedOn="{StaticResource MetroBaseWindowButtonStyle}" />

    <!-- style for default button -->
    <Style TargetType="{x:Type Button}"
           x:Key="MetroButton">
        <Setter Property="MinHeight"
                Value="25" />
        <Setter Property="FontWeight"
                Value="Bold" />
        <Setter Property="FontSize"
                Value="{DynamicResource UpperCaseContentFontSize}" />
        <Setter Property="FontFamily"
                Value="{DynamicResource DefaultFont}" />
        <Setter Property="Background"
                Value="{DynamicResource GrayBrush10}" />
        <Setter Property="BorderBrush"
                Value="{DynamicResource TextBoxBorderBrush}" />
        <Setter Property="Foreground"
                Value="{DynamicResource TextBrush}" />
        <Setter Property="Padding"
                Value="5,6" />
        <Setter Property="BorderThickness"
                Value="1" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Grid>
                        <Border x:Name="Background"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                Background="{TemplateBinding Background}"
                                CornerRadius="3" />
                        <Rectangle x:Name="DisabledVisualElement"
                                   Fill="{DynamicResource ControlsDisabledBrush}"
                                   IsHitTestVisible="false"
                                   Opacity="0"
                                   RadiusY="3"
                                   RadiusX="3" />
                        <ContentPresenter x:Name="contentPresenter"
                                          RecognizesAccessKey="True"
                                          ContentTemplate="{TemplateBinding ContentTemplate}"
                                          Content="{TemplateBinding Content, Converter={StaticResource ToUpperConverter}}"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          Margin="{TemplateBinding Padding}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver"
                                 Value="True">
                            <Setter TargetName="Background"
                                    Property="Background"
                                    Value="{DynamicResource GrayBrush8}" />
                        </Trigger>
                        <Trigger Property="IsPressed"
                                 Value="True">
                            <Setter TargetName="Background"
                                    Property="Background"
                                    Value="{DynamicResource GrayBrush7}" />
                        </Trigger>
                        <Trigger Property="IsKeyboardFocusWithin"
                                 Value="True">
                            <Setter TargetName="Background"
                                    Property="BorderThickness"
                                    Value="2" />
                            <Setter TargetName="Background"
                                    Property="BorderBrush"
                                    Value="{DynamicResource ButtonMouseOverBorderBrush}" />
                        </Trigger>
                        <Trigger Property="IsEnabled"
                                 Value="False">
                            <Setter TargetName="DisabledVisualElement"
                                    Property="Opacity"
                                    Value="0.7" />
                            <Setter TargetName="contentPresenter"
                                    Property="Opacity"
                                    Value="0.3" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="SquareButtonStyle"
           TargetType="{x:Type Button}">
        <Setter Property="MinHeight"
                Value="25" />
        <Setter Property="FontFamily"
                Value="{DynamicResource DefaultFont}" />
        <Setter Property="FontWeight"
                Value="SemiBold" />
        <Setter Property="Background"
                Value="{DynamicResource WhiteBrush}" />
        <Setter Property="BorderBrush"
                Value="{DynamicResource BlackBrush}" />
        <Setter Property="Foreground"
                Value="{DynamicResource TextBrush}" />
        <Setter Property="Padding"
                Value="5,6" />
        <Setter Property="BorderThickness"
                Value="1" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)"
                                                                       Storyboard.TargetName="MouseOverBorder">
                                            <EasingDoubleKeyFrame KeyTime="0"
                                                                  Value="1" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <ThicknessAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderThickness)"
                                                                          Storyboard.TargetName="MouseOverBorder">
                                            <EasingThicknessKeyFrame KeyTime="0"
                                                                     Value="2" />
                                        </ThicknessAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)"
                                                                       Storyboard.TargetName="PressedBorder">
                                            <EasingDoubleKeyFrame KeyTime="0"
                                                                  Value="1" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <ThicknessAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderThickness)"
                                                                          Storyboard.TargetName="MouseOverBorder">
                                            <EasingThicknessKeyFrame KeyTime="0"
                                                                     Value="0" />
                                        </ThicknessAnimationUsingKeyFrames>
                                        <ThicknessAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderThickness)"
                                                                          Storyboard.TargetName="PressedBorder">
                                            <EasingThicknessKeyFrame KeyTime="0"
                                                                     Value="2" />
                                        </ThicknessAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity"
                                                                       Storyboard.TargetName="DisabledVisualElement">
                                            <SplineDoubleKeyFrame KeyTime="0"
                                                                  Value="0.7" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)"
                                                                       Storyboard.TargetName="contentPresenter">
                                            <EasingDoubleKeyFrame KeyTime="0"
                                                                  Value="0.3" />
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Focused" />
                                <VisualState x:Name="Unfocused" />
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="ValidationStates">
                                <VisualState x:Name="Valid" />
                                <VisualState x:Name="InvalidFocused" />
                                <VisualState x:Name="InvalidUnfocused" />
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Border x:Name="Background"
                                BorderBrush="{DynamicResource BlackBrush}"
                                BorderThickness="2"
                                Background="{TemplateBinding Background}" />
                        <Rectangle x:Name="DisabledVisualElement"
                                   Fill="{DynamicResource ControlsDisabledBrush}"
                                   IsHitTestVisible="false"
                                   Opacity="0" />
                        <Border x:Name="MouseOverBorder"
                                Background="{DynamicResource GrayBrush8}"
                                Opacity="0" />
                        <Border x:Name="PressedBorder"
                                Background="{DynamicResource BlackBrush}"
                                Opacity="0"
                                BorderBrush="{DynamicResource BlackBrush}" />
                        <ContentPresenter x:Name="contentPresenter"
                                          ContentTemplate="{TemplateBinding ContentTemplate}"
                                          Content="{TemplateBinding Content, Converter={StaticResource ToLowerConverter}}"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          Margin="{TemplateBinding Padding}"
                                          RecognizesAccessKey="True"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                          OpacityMask="{x:Null}" />
                    </Grid>

                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver"
                                 Value="True">
                            <Setter Property="Foreground"
                                    Value="{DynamicResource BlackBrush}" />
                        </Trigger>
                        <Trigger Property="IsPressed"
                                 Value="true">
                            <Setter Property="Foreground"
                                    Value="{DynamicResource WhiteBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="AccentedSquareButtonStyle"
           BasedOn="{StaticResource SquareButtonStyle}"
           TargetType="{x:Type Button}">
        <Setter Property="Background"
                Value="{DynamicResource AccentColorBrush}" />
        <Setter Property="Foreground"
                Value="{DynamicResource IdealForegroundColorBrush}" />
    </Style>

    <Style x:Key="HighlightedSquareButtonStyle"
           BasedOn="{StaticResource SquareButtonStyle}"
           TargetType="{x:Type Button}">
        <Setter Property="Background"
                Value="{DynamicResource HighlightBrush}" />
        <Setter Property="Foreground"
                Value="{DynamicResource IdealForegroundColorBrush}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)"
                                                                       Storyboard.TargetName="MouseOverBorder">
                                            <EasingDoubleKeyFrame KeyTime="0"
                                                                  Value="1" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <ThicknessAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderThickness)"
                                                                          Storyboard.TargetName="MouseOverBorder">
                                            <EasingThicknessKeyFrame KeyTime="0"
                                                                     Value="2" />
                                        </ThicknessAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)"
                                                                       Storyboard.TargetName="PressedBorder">
                                            <EasingDoubleKeyFrame KeyTime="0"
                                                                  Value="1" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <ThicknessAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderThickness)"
                                                                          Storyboard.TargetName="MouseOverBorder">
                                            <EasingThicknessKeyFrame KeyTime="0"
                                                                     Value="0" />
                                        </ThicknessAnimationUsingKeyFrames>
                                        <ThicknessAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderThickness)"
                                                                          Storyboard.TargetName="PressedBorder">
                                            <EasingThicknessKeyFrame KeyTime="0"
                                                                     Value="2" />
                                        </ThicknessAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity"
                                                                       Storyboard.TargetName="DisabledVisualElement">
                                            <SplineDoubleKeyFrame KeyTime="0"
                                                                  Value="0.7" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)"
                                                                       Storyboard.TargetName="contentPresenter">
                                            <EasingDoubleKeyFrame KeyTime="0"
                                                                  Value="0.3" />
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Focused" />
                                <VisualState x:Name="Unfocused" />
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="ValidationStates">
                                <VisualState x:Name="Valid" />
                                <VisualState x:Name="InvalidFocused" />
                                <VisualState x:Name="InvalidUnfocused" />
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Border x:Name="Background"
                                BorderBrush="{DynamicResource BlackBrush}"
                                BorderThickness="2"
                                Background="{TemplateBinding Background}" />
                        <Rectangle x:Name="DisabledVisualElement"
                                   Fill="{DynamicResource ControlsDisabledBrush}"
                                   IsHitTestVisible="false"
                                   Opacity="0" />
                        <Border x:Name="MouseOverBorder"
                                Background="{DynamicResource AccentColorBrush}"
                                Opacity="0" />
                        <Border x:Name="PressedBorder"
                                Background="{DynamicResource BlackBrush}"
                                Opacity="0"
                                BorderBrush="{DynamicResource BlackBrush}" />
                        <ContentPresenter x:Name="contentPresenter"
                                          ContentTemplate="{TemplateBinding ContentTemplate}"
                                          Content="{TemplateBinding Content, Converter={StaticResource ToLowerConverter}}"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          Margin="{TemplateBinding Padding}"
                                          RecognizesAccessKey="True"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                          OpacityMask="{x:Null}" />
                    </Grid>

                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver"
                                 Value="True">
                            <Setter Property="Foreground"
                                    Value="{DynamicResource IdealForegroundColorBrush}" />
                        </Trigger>
                        <Trigger Property="IsPressed"
                                 Value="true">
                            <Setter Property="Foreground"
                                    Value="{DynamicResource WhiteBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="MetroCircleToggleButtonStyle"
           TargetType="{x:Type ToggleButton}">
        <Setter Property="FocusVisualStyle"
                Value="{StaticResource MetroCircleButtonFocusVisual}" />
        <Setter Property="Background"
                Value="Transparent" />
        <Setter Property="BorderThickness"
                Value="2" />
        <Setter Property="HorizontalContentAlignment"
                Value="Center" />
        <Setter Property="Foreground"
                Value="{DynamicResource BlackBrush}" />
        <Setter Property="VerticalContentAlignment"
                Value="Center" />
        <Setter Property="Padding"
                Value="1" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Grid>
                        <Ellipse Fill="{TemplateBinding Background}"
                                 Margin="4"
                                 StrokeThickness="0" />
                        <Ellipse x:Name="ellipsebg"
                                 Fill="{DynamicResource AccentColorBrush}"
                                 Opacity="0"
                                 Margin="4"
                                 StrokeThickness="0" />
                        <Ellipse x:Name="ellipse"
                                 Margin="4"
                                 Stroke="#ADADAD"
                                 StrokeThickness="{Binding RelativeSource={x:Static RelativeSource.TemplatedParent}, Path=BorderThickness.Left}" />
                        <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          Margin="{TemplateBinding Padding}"
                                          RecognizesAccessKey="True"
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="ToggleButton.IsChecked"
                                 Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="ellipsebg"
                                                         Storyboard.TargetProperty="Opacity"
                                                         From="0"
                                                         To="1"
                                                         Duration="0:0:0.3" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.EnterActions>
                            <!-- some out fading -->
                            <Trigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="ellipsebg"
                                                         Storyboard.TargetProperty="Opacity"
                                                         To="0"
                                                         Duration="0:0:0.3" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.ExitActions>
                            <Setter Property="Foreground"
                                    Value="{DynamicResource IdealForegroundColorBrush}" />
                            <Setter TargetName="ellipse"
                                    Property="Stroke"
                                    Value="{DynamicResource AccentColorBrush}" />
                        </Trigger>
                        <Trigger Property="IsMouseOver"
                                 Value="True">
                            <Setter TargetName="ellipse"
                                    Property="Opacity"
                                    Value="1" />
                        </Trigger>
                        <Trigger Property="IsMouseOver"
                                 Value="False">
                            <Setter TargetName="ellipse"
                                    Property="Opacity"
                                    Value=".5" />
                        </Trigger>
                        <Trigger Property="IsEnabled"
                                 Value="False">
                            <Setter Property="Foreground"
                                    Value="{DynamicResource GrayBrush7}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="ToggleButton"
           x:Key="MetroToggleButton">
        <Setter Property="Background"
                Value="{DynamicResource GrayBrush10}" />
        <Setter Property="BorderBrush"
                Value="{DynamicResource TextBoxBorderBrush}" />
        <Setter Property="Foreground"
                Value="{DynamicResource TextBrush}" />
        <Setter Property="FontFamily"
                Value="{DynamicResource DefaultFont}" />
        <Setter Property="FontSize"
                Value="{DynamicResource UpperCaseContentFontSize}" />
        <Setter Property="FontWeight"
                Value="Bold" />
        <Setter Property="Padding"
                Value="5,6" />
        <Setter Property="BorderThickness"
                Value="1" />
        <Setter Property="MinHeight"
                Value="25" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ToggleButton">
                    <Grid>
                        <Border x:Name="Background"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                Background="{TemplateBinding Background}"
                                CornerRadius="3" />
                        <Rectangle x:Name="DisabledVisualElement"
                                   Fill="{DynamicResource WhiteBrush}"
                                   IsHitTestVisible="false"
                                   Opacity="0"
                                   RadiusY="3"
                                   RadiusX="3" />
                        <ContentPresenter x:Name="contentPresenter"
                                          RecognizesAccessKey="True"
                                          ContentTemplate="{TemplateBinding ContentTemplate}"
                                          Content="{TemplateBinding Content}"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          Margin="{TemplateBinding Padding}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked"
                                 Value="True">
                            <Setter TargetName="Background"
                                    Property="BorderThickness"
                                    Value="2" />
                            <Setter TargetName="Background"
                                    Property="Background"
                                    Value="{DynamicResource GrayBrush2}" />
                            <Setter TargetName="Background"
                                    Property="BorderBrush"
                                    Value="{DynamicResource GrayBrush5}" />
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver"
                                           Value="True" />
                                <Condition Property="IsChecked"
                                           Value="False" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="Background"
                                    Property="Background"
                                    Value="{DynamicResource GrayBrush8}" />
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver"
                                           Value="True" />
                                <Condition Property="IsChecked"
                                           Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="Background"
                                    Property="Background"
                                    Value="{DynamicResource GrayBrush3}" />
                        </MultiTrigger>
                        <Trigger Property="IsPressed"
                                 Value="True">
                            <Setter TargetName="Background"
                                    Property="Background"
                                    Value="{DynamicResource GrayBrush7}" />
                        </Trigger>
                        <Trigger Property="IsKeyboardFocusWithin"
                                 Value="True">
                            <Setter TargetName="Background"
                                    Property="BorderThickness"
                                    Value="2" />
                            <Setter TargetName="Background"
                                    Property="BorderBrush"
                                    Value="{DynamicResource ButtonMouseOverBorderBrush}" />
                        </Trigger>
                        <Trigger Property="IsEnabled"
                                 Value="False">
                            <Setter TargetName="DisabledVisualElement"
                                    Property="Opacity"
                                    Value="0.7" />
                            <Setter TargetName="contentPresenter"
                                    Property="Opacity"
                                    Value="0.3" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type Button}"
           x:Key="SquareMetroButton">
        <Setter Property="Background"
                Value="Transparent" />
        <Setter Property="Foreground"
                Value="{DynamicResource BlackBrush}" />
        <Setter Property="BorderBrush"
                Value="{DynamicResource BlackBrush}" />
        <Setter Property="BorderThickness"
                Value="2" />
        <Setter Property="Padding"
                Value="12,4,12,4" />
        <Setter Property="HorizontalAlignment"
                Value="Left" />
        <Setter Property="VerticalAlignment"
                Value="Center" />
        <Setter Property="FontFamily"
                Value="{DynamicResource DefaultFont}" />
        <Setter Property="FontWeight"
                Value="SemiBold" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetProperty="(UIElement.Opacity)"
                                                         Storyboard.TargetName="MouseOverRectangle"
                                                         To="0.4"
                                                         Duration="0" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetProperty="(UIElement.Opacity)"
                                                         Storyboard.TargetName="PressedRectangle"
                                                         To="1"
                                                         Duration="0" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetProperty="(UIElement.Opacity)"
                                                         Storyboard.TargetName="Border"
                                                         To="0.5"
                                                         Duration="0" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Focused">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="FocusVisualWhite"
                                                         Storyboard.TargetProperty="Opacity"
                                                         To="1"
                                                         Duration="0" />
                                        <DoubleAnimation Storyboard.TargetName="FocusVisualBlack"
                                                         Storyboard.TargetProperty="Opacity"
                                                         To="1"
                                                         Duration="0" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Unfocused" />
                                <VisualState x:Name="PointerFocused" />
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>

                        <Border x:Name="Border"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}">

                            <Grid>
                                <Rectangle x:Name="MouseOverRectangle"
                                           Fill="{DynamicResource WhiteBrush}"
                                           Opacity="0" />
                                <Rectangle x:Name="PressedRectangle"
                                           Fill="{DynamicResource BlackBrush}"
                                           Opacity="0" />

                                <ContentPresenter x:Name="ContentPresenter"
                                                  TextBlock.Foreground="{TemplateBinding Foreground}"
                                                  Content="{TemplateBinding Content}"
                                                  ContentTemplate="{TemplateBinding ContentTemplate}"
                                                  Margin="{TemplateBinding Padding}"
                                                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                            </Grid>
                        </Border>

                        <Rectangle x:Name="FocusVisualWhite"
                                   IsHitTestVisible="False"
                                   Stroke="White"
                                   StrokeEndLineCap="Square"
                                   StrokeDashArray="1,1"
                                   Opacity="0"
                                   StrokeDashOffset="1.5" />
                        <Rectangle x:Name="FocusVisualBlack"
                                   IsHitTestVisible="False"
                                   Stroke="Black"
                                   StrokeEndLineCap="Square"
                                   StrokeDashArray="1,1"
                                   Opacity="0"
                                   StrokeDashOffset="0.5" />
                    </Grid>

                    <ControlTemplate.Triggers>
                        <Trigger Property="IsPressed"
                                 Value="True">
                            <Setter Property="Foreground"
                                    Value="{DynamicResource WhiteBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type Button}"
           x:Key="MetroAccentButton"
           BasedOn="{StaticResource SquareMetroButton}">
        <Setter Property="Foreground"
                Value="{DynamicResource AccentSelectedColorBrush}" />
        <Setter Property="BorderBrush"
                Value="{DynamicResource AccentSelectedColorBrush}" />
        <Setter Property="Background"
                Value="{DynamicResource AccentColorBrush}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetProperty="(UIElement.Opacity)"
                                                         Storyboard.TargetName="MouseOverRectangle"
                                                         To="0.4"
                                                         Duration="0" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetProperty="(UIElement.Opacity)"
                                                         Storyboard.TargetName="PressedRectangle"
                                                         To="1"
                                                         Duration="0" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetProperty="(UIElement.Opacity)"
                                                         Storyboard.TargetName="Border"
                                                         To="0.5"
                                                         Duration="0" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Focused">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="FocusVisualWhite"
                                                         Storyboard.TargetProperty="Opacity"
                                                         To="1"
                                                         Duration="0" />
                                        <DoubleAnimation Storyboard.TargetName="FocusVisualBlack"
                                                         Storyboard.TargetProperty="Opacity"
                                                         To="1"
                                                         Duration="0" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Unfocused" />
                                <VisualState x:Name="PointerFocused" />
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>

                        <Border x:Name="Border"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}">

                            <Grid>
                                <Rectangle x:Name="MouseOverRectangle"
                                           Fill="{DynamicResource BlackBrush}"
                                           Opacity="0" />
                                <Rectangle x:Name="PressedRectangle"
                                           Fill="White"
                                           Opacity="0" />

                                <ContentPresenter x:Name="ContentPresenter"
                                                  TextBlock.Foreground="{TemplateBinding Foreground}"
                                                  Content="{TemplateBinding Content}"
                                                  ContentTemplate="{TemplateBinding ContentTemplate}"
                                                  Margin="{TemplateBinding Padding}"
                                                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                            </Grid>
                        </Border>

                        <Rectangle x:Name="FocusVisualWhite"
                                   IsHitTestVisible="False"
                                   Stroke="White"
                                   StrokeEndLineCap="Square"
                                   StrokeDashArray="1,1"
                                   Opacity="0"
                                   StrokeDashOffset="1.5" />
                        <Rectangle x:Name="FocusVisualBlack"
                                   IsHitTestVisible="False"
                                   Stroke="Black"
                                   StrokeEndLineCap="Square"
                                   StrokeDashArray="1,1"
                                   Opacity="0"
                                   StrokeDashOffset="0.5" />
                    </Grid>

                    <ControlTemplate.Triggers>
                        <Trigger Property="IsPressed"
                                 Value="True">
                            <Setter Property="Foreground"
                                    Value="Black" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
